package com.dc.dao;

import com.dc.entity.ShipRepairEntity;
import com.dc.entity.WorkflowElectricBoxEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface WorkflowElectricBoxDao extends JpaRepository<WorkflowElectricBoxEntity, Long>, JpaSpecificationExecutor<WorkflowElectricBoxEntity> {

    Page<WorkflowElectricBoxEntity> findByShipRepairEntity(ShipRepairEntity shipRepair, Pageable pageable);

    List<WorkflowElectricBoxEntity> findByShipRepairEntity(ShipRepairEntity shipRepair);

    @Transactional
    @Modifying
    @Query(value = "update WorkflowElectricBoxEntity set power = :power where mfid = :mfid")
    int updatePowerByMfid(@Param("mfid") String mfid, @Param("power") Double power);


}

